/******************************************************************************
** @file	ProcessTest.cpp
** @author  
**
** @date	Jul 20, 2010
**
** @desc	This test lists the processes that estan running in the operating
**			system.
*			
**
******************************************************************************/

#include "../Unit--/unit--.h"
#include "../../WMI_Process.h"
#include "../../wmi_connection.h"
#include "../../wmi_connectionmanager.h"
#include "../../wmi_result.h"
#include "../../wmi_constants.h"

using namespace unit_minus;

testSuite(WMIReaderSuite);

testCase(WProcessTest1, WMIReaderSuite)
{
    cout << "---------- Start Process Test ----------" << endl;
	WMI_Connection con;
	WMI_ConnectionManager* mng = new WMI_ConnectionManager();
	mng->initCOMSecurityConfiguration();

	mng->createConnection(PC_USER, PC_PASSWORD, PC_NAMESPACE, con);

	con.executeQuery(L"SELECT * FROM Win32_Process");

	if (con.getIEnumWbemClassObject() != NULL)
	{
		IEnumWbemClassObject* pEnumerator = NULL;
		pEnumerator = con.getIEnumWbemClassObject();
		
		WMI_Result<WMI_Process> res;
		res.fillVector(pEnumerator);

		assertTrue(res.getObjects().size() != 0);
	}
	else
	{
		cout << "The test failure......" << endl;
	}

    con.close();
    cout << "---------- End Process Test ----------" << endl << endl;
    system("PAUSE");
}